package com.itheima.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//自定义处理类
public class UserController implements Controller {
    @Override
    //自调用的方法
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {

        ModelAndView mv = new ModelAndView();
        System.out.println("被请求了");

        /*
        * ModelAndView:
        * model:数据模型
        * view:视图
        *       物理视图
        *       逻辑视图
        * */
        //设置物理视图
        //redirect:重定向,没走视图解析器
        //mv.setViewName("redirect:/pages/index.jsp");
        //逻辑视图
        mv.setViewName("/index");
        return mv;
    }
}
